// ExtractCorner.cpp : implementation file
//

#include "stdafx.h"
#include "manualCalib.h"
#include "ExtractCorner.h"


// CExtractCorner dialog

IMPLEMENT_DYNAMIC(CExtractCorner, CDialog)

CExtractCorner::CExtractCorner(CWnd* pParent /*=NULL*/)
	: CDialog(CExtractCorner::IDD, pParent)
{

}

CExtractCorner::~CExtractCorner()
{
}

//added
void CExtractCorner::addImage(IplImage *rgbImage, CvxBoard *board)
{
	ASSERT(rgbImage);
	ASSERT(board);
	m_cornerPic.addImage(rgbImage, board);
	m_imageSize = cvSize(rgbImage->width, rgbImage->height);
	
}
void CExtractCorner::setPts(vector<Point2f> *pts)
{
	ASSERT(pts);
	m_cornerPic.setPts(pts);
}

void CExtractCorner::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EXTRACT_CORNER_PIC, m_cornerPic);
}


BEGIN_MESSAGE_MAP(CExtractCorner, CDialog)
END_MESSAGE_MAP()


// CExtractCorner message handlers

BOOL CExtractCorner::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here

	//set dialog and picture control position and size
	CRect temprect(0, 0, 1060, 600);   
	CWnd::SetWindowPos(NULL,0,0,temprect.Width(),temprect.Height(),SWP_NOZORDER|SWP_NOMOVE);
	if (m_imageSize.width%960 != 0)
	{
		if (m_imageSize.width > 960)
		{
			if (m_imageSize.width > 1920)
			{
				m_cornerPic.MoveWindow(0, 0, m_imageSize.width/4, m_imageSize.height/4);
			}
			else
			{
				m_cornerPic.MoveWindow(0, 0, m_imageSize.width/2, m_imageSize.height/2);
			}			
		}
		else
		{
			m_cornerPic.MoveWindow(0, 0, m_imageSize.width, m_imageSize.height);
		}
	}
	else
	{
		m_cornerPic.MoveWindow(0, 0, 960, 540);
	}
	m_setPts = false;

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
